// pages/functions/jumpPage/popularize/waterTicket.js
const util = require('../../../../utils/util.js')
import {
  list as orderAdminList
} from '../../../../api/orderAdmin'
import {
  getInfo
} from '../../../../api/mch'
import {findByWater} from '../../../../api/bom'
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageNum: 1,
    pageSize: 1,
    isShow: false,
    length: '',
    mch: {},
    waters: [],
    memberId:'',
    tabbarHeight: app.globalData.tabbarHeight,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    this.memberId = options.id
    console.log('传过来的 memberID',this.memberId)
    var  _this = this
    this.loadProduct()
    this.loadMch()
    // this.gettabBarHeight()
  },
  onShow: function () {
    // this.loadProduct()
    // if (typeof this.getTabBar === 'function' &&this.getTabBar()) {
    //     this.getTabBar().setData({
    //     selected: 1
    //     })
    // }
    
  },
 
  loadMch() {
    var _this = this;
    getInfo(app.globalData.mchId).then(res => {
      console.log(res.data,'mch')
      _this.data.mch = res.data;
      _this.setData({
        mch: _this.data.mch
      })
    });
  },
  toIndex() {
    wx.switchTab({
      url: '/pages/index/index'
    })
  },
  loadProduct() {
    orderAdminList({
      memberId:this.memberId,
      subType: '2'
    }).then(res => {
      this.data.waters = res.data.data
      console.log(this.data.waters,"localStorage")
      this.setData({
        waters: this.data.waters
      })
    })
  },
  usetransfer(e){
    return;
      wx.navigateTo({
        url: '/pages/member/waterTransfer/index?virtualStockId='+e.currentTarget.dataset.id,
    })
},
  useCoupon(e) {
    return;
    this.gettabBarHeight()
    this.data.isShow = true
    findByWater({
      productId:e.currentTarget.dataset.id
    }).then(res=>{
          this.selectComponent('#bottomFrame').showFrame(res.data.productId, "buyNow");
    })
    this.setData({
      isShow: this.data.isShow
    })
  },
  gettabBarHeight:function(){
    var tabBarType = 1
    wx.setStorageSync('tabBarType', tabBarType)
  }
})